import Vue from 'vue'
import Component from './loading_UI.vue'

//Vue实例化
const Loading_UIConstructor = Vue.extend(Component)

var instance = null;

const loading_UI = {};

loading_UI.show = (options) => {

    instance = new Loading_UIConstructor({
        propsData : options 
    })

    //创建一个随机id
    instance.id = 1001

    //把id挂载到dom上
    instance.vm = instance.$mount()

    instance.vm.rgba = "rgba(0,0,0,0.5)"

    //创建一个dom实例
    document.body.appendChild(instance.vm.$el)

    return instance.vm

}

loading_UI.noMaskShow = (options) => {

    instance = new Loading_UIConstructor({
        propsData : options 
    })

    //创建一个随机id
    instance.id = 1001

    //把id挂载到dom上
    instance.vm = instance.$mount()

    //创建一个dom实例
    document.body.appendChild(instance.vm.$el)

    return instance.vm

}

loading_UI.hide = () => {

    try {

        instance.vm.isVisible = true;

        instance.vm.rgba = "rgba(0,0,0,0)"

        document.body.removeChild(instance.vm.$el)

    }catch(err){

        

    }
    

}

export default loading_UI